<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" session="false" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%
    Integer pageA = "".equals(request.getParameter("page")) || request.getParameter("page")==null ? 1 : Integer.parseInt(request.getParameter("page"));
    request.setAttribute("pageA",pageA);
    String keyword = request.getParameter("keyword");
    request.setAttribute("keyword",keyword);
%>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>聊天室-管理后台-用户</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="/static/css/bootstrap.min.css" />
    <style type="text/css">*{margin:0; padding:0;} body{overflow-x: hidden;}</style>
    <script type="text/javascript">
        function actionSearch(page){
            var keyWord = document.getElementById("searchKeyword").value.trim();
            window.location.href = "/admin/user_list?page="+page+"&keyWord="+keyWord+"";
        };
    </script>
</head>
<body>

<div class="row" style="padding:30px;">
    <div class="col-md-12" style="text-align: right;">
        <a href="/admin/logout">退出管理后台</a>
    </div>
    <div class="col-md-8">
        <div class="form-inline" style="padding-bottom: 10px;">
            <input type="email" class="form-control" id="searchKeyword" placeholder="请输入需搜索keyword">
            <button type="submit" class="btn btn-success" onclick="actionSearch(${pageA})">搜索</button>
        </div>
        <table class="table table-bordered">
            <tr>
                <th>用户ID</th>
                <th>用户名</th>
                <th>昵称</th>
                <th>性别</th>
                <th>个人头像</th>
                <th>个人介绍</th>
                <th>最后登录时间</th>
                <th>注册时间</th>
                <th>账号状态</th>
                <th>状态原因描述</th>
                <th>禁言截止时间</th>
                <th>已创建“聊天室”数量</th>
                <th>可创建“聊天室”总数</th>
            </tr>
            <c:forEach items="${list}" var="newList">
                <tr>
                    <td>${newList.id}</td>
                    <td>${newList.name}</td>
                    <td>${newList.nickname}</td>
                    <td>${newList.sex}</td>
                    <td>${newList.profilehead}</td>
                    <td>${newList.profile}</td>
                    <td>${newList.signtime}</td>
                    <td>${newList.creattime}</td>
                    <td>${newList.status}</td>
                    <td>${newList.statusdetails}</td>
                    <td>${newList.statustime}</td>
                    <td>${newList.chatroom}</td>
                    <td>${newList.canchatroom}</td>
                </tr>
            </c:forEach>
        </table>

        <ul class="pagination" style="float:right; ">
            <c:if test="${pager.current_page < 2}">
                <li class="disabled" style="pointer-events:none">
            </c:if>
            <c:if test="${pager.current_page > 1}">
                <li class="">
            </c:if>
                <a href="/admin/user_list?page=${pager.prev_page}&keyWord=${keyword}" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>

            <c:if test="${pager.current_page-2 > 0}">
                <li><a href="/admin/user_list?page=${pager.current_page-2}&keyWord=${keyword}">${pager.current_page-2}</a></li>
            </c:if>
            <c:if test="${pager.current_page-1 > 0}">
                <li><a href="/admin/user_list?page=${pager.current_page-1}&keyWord=${keyword}">${pager.current_page-1}</a></li>
            </c:if>
            <li class="disabled"><a href="/admin/user_list?page=${pager.current_page}&keyWord=${keyword}">${pager.current_page}</a></li>
            <c:if test="${pager.current_page+1 <= pager.total_page}">
                <li><a href="/admin/user_list?page=${pager.current_page+1}&keyWord=${keyword}">${pager.current_page+1}</a></li>
            </c:if>
            <c:if test="${pager.current_page+2 <= pager.total_page}">
                <li><a href="/admin/user_list?page=${pager.current_page+2}&keyWord=${keyword}">${pager.current_page+2}</a></li>
            </c:if>

                <c:if test="${pager.current_page >= pager.total_page}">
                    <li class="disabled" style="pointer-events:none">
                </c:if>
                <c:if test="${pager.current_page < pager.total_page}">
                    <li class="">
                </c:if>
                <a href="/admin/user_list?page=${pager.next_page}&keyWord=${keyword}" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
        </ul>
        <p style="display:inline-block; float:right; line-height: 74px; padding-right: 50px;">
            当前页面：${pager.current_page},
            每页显示条数：${pager.page_size},
            上一页码：${pager.prev_page},
            下一页码：${pager.next_page},
            总条数：${pager.total_count},
            总页数：${pager.total_page}
        </p>
    </div>


</body>
</html>
